/**
* 弹窗组件，使用： this.$store.dispatch('setModal', {visible: true, modalId: 'tradeToRealModal',stockCode:'',marketCd:'',tradeType:''}); 注意this指向的上下文环境，有时候是写self或其它
* tradeType:   'buy':股票真实账户-购买  'sell':股票真实账户-卖出   'fund'基金真实账户
*/
<template>
  <transition name="slide-fade">
    <div v-if="modal.visible && modal.modalId=='tradeToRealModal'" class="modal" id="tradeToRealModal" tabindex="-1" @click.stop.prevent="modalHide">
      <div class="modal-dialog trade-warning" @click.stop.prevent>
        <div class="modal-dialog-title"><img src="~assets/images/trade-warning.png">风险提示</div>
        <img src="~assets/images/close@2x.png" data-dismiss="modal" class="img-close" @click.stop.prevent="modalHide">
        <div class="modal-dialog-content">
          <div>您即将<span class="color-orange">转入实盘进行真实操作</span>，这可能造成资金损失，请确认转入实盘进行操作！</div>
          <div class="m-t-sm">投资有风险，转入实盘需谨慎</div>
          <div class="modal-dialog-btn m-t-sm" id="confirmGoReal" @click="toReal">我确认转入实盘</div>
        </div>
      </div>
    </div>
  </transition>
</template>

<script>
  import BaseModal from 'components/modal/BaseModal'
  import RemoteDAO from 'common/remoteDAO'
  import LocalDAO from 'common/localDAO'
  import CommonUtil from 'common/common.util'

  export default {
    data () {
      return {
      }
    },
    extends:BaseModal,
    methods:{
      toReal(){
        if(this.modal.tradeType == 'fund'){
          window.location.href = 'gtjayyz://jumpfunc?funid=20019&tabid=1';
        }else{
          let type = (this.modal.tradeType == "sell" ? this.modal.tradeType : "buy");
          TDAPP.onEvent((this.modal.tradeType == "sell" ? "4002" : "4001"), "", {'usercode': LocalDAO.getUserCode()});
          TDAPP.send();
          let stockCode = CommonUtil.isEmpty(this.modal.stockCode) ? "" : (this.modal.marketCd  + this.modal.stockCode);
          window.location.href = "gtjanrng://jumpToFirm?stockcode=" + stockCode + "&direction=" + type;
        }
      }
    }
  }
</script>

<style scoped>
  .slide-fade-enter-active,.slide-fade-leave-active{
    transition: all 0.3s ease;
  }
  .slide-fade-enter, .slide-fade-leave-active {
    transform: translate(0,-25%);
    opacity: 0;
  }

  .img-close{
    position: absolute;
    top: 15px;
    right: 40px;
    width: 30px;
    z-index: 999;
  }
</style>
